#!/bin/sh

CWD=`pwd`
INSTALL_DIR="$CWD/../.."
LIB_DIR="$INSTALL_DIR/lib"

LIB_DEBUG="$LIB_DIR/libcppsocket_d.a"
LIB_RELEASE="$LIB_DIR/libcppsocket.a"

if ! [ -e $LIB_DEBUG ]
then
    ./configure --prefix=$INSTALL_DIR --enable-shared=no --enable-static=yes --enable-debug=yes
    make && make install && make distclean
    if [ $? -ne 0 ]
    then
        exit $?
    fi
    mv $LIB_RELEASE $LIB_DEBUG
fi

if ! [ -e $LIB_RELEASE ]
then
    ./configure --prefix=$INSTALL_DIR --enable-shared=no --enable-static=yes
    make && make install && make distclean
    if [ $? -ne 0 ]
    then
        exit $?
    fi
fi

exit 0
